<!DOCTYPE html>

<html>



<head>

    <meta charset="UTF-8">

    <title>后台管理系统登陆</title>

    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link href="__PUBLIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

    <link href="__PUBLIC__/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/login/css/style.css">

    <style>

    #imgVerify {

        width: 120px;

        margin: 0 auto;

        text-align: center;

        display: block;

    }

    </style>

    <script>

    function checkBrowser() {

        var browser = navigator.appName;

        if (navigator.userAgent.indexOf("MSIE") > 0) { 

            var b_version = navigator.appVersion;

            var version = b_version.split(";");

            var trim_Version = version[1].replace(/[ ]/g, "");

            if ((browser == "Netscape" || browser == "Microsoft Internet Explorer")) {

                if (trim_Version == 'MSIE8.0' || trim_Version == 'MSIE7.0' || trim_Version == 'MSIE6.0') {

                    alert('请使用IE9.0版本以上进行访问');

                    return;

                }

            }

        }

    }

    checkBrowser();

    </script>

</head>



<body class="login-page">

    <div class="wrapper">

        <div class="container">

            <h1>后台管理系统</h1>

            <form class="form">

                <div class="form-group has-feedback">

                    <input type="text" name="username" id="username" placeholder="账号">

                </div>

                <div class="form-group has-feedback">

                    <input type="password" name="password" id="password" placeholder="密码">

                </div>

                <div class="form-group has-feedback">

                    <block realtime="true" opinion_name="vertify_code" default="true">

                        <div class="row row_box">

                            <div class="col-xs-8 vertify_box_parent">

                                <input class="vertify_box" type="text" name="vertify" placeholder="验证码" />

                            </div>

                            <div class="col-xs-4 imgVerify_parent">

                                <img id="imgVerify" style="cursor:pointer;width:106px;" src="{:U('Admin/vertify')}" onclick="fleshVerify();" />

                            </div>

                        </div>

                    </block>

                </div>

                <div class="form-group">

                    <button type="button" id="login-button" onclick="checkLogin()">立即登录</button>

                </div>

            </form>

        </div>

        <ul class="bg_bubbles">

            <li></li>

            <li></li>

            <li></li>

            <li></li>

            <li></li>

            <li></li>

            <li></li>

            <li></li>

            <li></li>

            <li></li>

        </ul>

    </div>

    <script src="__PUBLIC__/js/jQuery-2.1.4.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="__PUBLIC__/Admin/login/js/style.js"></script>

    <script src="__PUBLIC__/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

    <script src="__PUBLIC__/js/layer/layer.js"></script>

    <script>

    $(function() {

        $('#username').focus();

    });



    function fleshVerify() {

        $('#imgVerify').attr('src',"{:U('Admin/vertify')}/" + Math.floor(Math.random() * 100));

    }

    jQuery.fn.center = function() {

        this.css("position", "absolute");

        this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +

            $(window).scrollTop()) - 30 + "px");

        this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +

            $(window).scrollLeft()) + "px");

        return this;

    }



    function checkLogin() {

        var username = $('#username').val();

        var password = $('#password').val();

        var vertify = $('input[name="vertify"]').val();

        if (username == '' || password == '') {

            layer.alert('用户名或密码不能为空', {

                icon: 2

            });

            return;

        }

        if (vertify == '') {

            layer.alert('验证码不能为空', {

                icon: 2

            });

            return;

        }

        if (vertify.length != 4) {

            layer.alert('验证码错误', {

                icon: 2

            });

            return;

        }



        $.ajax({

            url: "{:U('Admin/login')}",

            type: 'post',

            dataType: 'json',

            data: {

                username: username,

                password: password,

                vertify: vertify

            },

            success: function(res) {

                if (res.status == 1) {

                    top.location.href = res.url;

                } else {

                    layer.alert(res.msg, {

                        icon: 2

                    });

                }

            },

            error: function(XMLHttpRequest, textStatus, errorThrown) {

                layer.alert('网络失败，请刷新页面后重试', {

                    icon: 2

                });

            }

        });

    }

    document.onkeydown = function(event) {

        e = event ? event : (window.event ? window.event : null);

        if (e.keyCode == 13) {

            checkLogin();

        }

    }

    </script>

</body>



</html>

